package com.HuiShou.controller.admin;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.HuiShou.common.annotation.Log;
import com.HuiShou.common.core.controller.BaseController;
import com.HuiShou.common.core.domain.AjaxResult;
import com.HuiShou.common.enums.BusinessType;
import com.HuiShou.domain.UserPointsDetail;
import com.HuiShou.service.IUserPointsDetailService;
import com.HuiShou.common.utils.poi.ExcelUtil;
import com.HuiShou.common.core.page.TableDataInfo;

/**
 * 积分明细Controller
 * 
 * @author lyz
 * @date 2025-03-21
 */
@RestController
@RequestMapping("/integral/detail")
public class PointsDetailController extends BaseController
{
    @Autowired
    private IUserPointsDetailService userPointsDetailService;

    /**
     * 查询积分明细列表
     */
    @PreAuthorize("@ss.hasPermi('integral:detail:list')")
    @GetMapping("/list")
    public TableDataInfo list(UserPointsDetail userPointsDetail)
    {
        startPage();
        List<UserPointsDetail> list = userPointsDetailService.selectUserPointsDetailList(userPointsDetail);
        return getDataTable(list);
    }

    /**
     * 导出积分明细列表
     */
    @PreAuthorize("@ss.hasPermi('integral:detail:export')")
    @Log(title = "积分明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UserPointsDetail userPointsDetail)
    {
        List<UserPointsDetail> list = userPointsDetailService.selectUserPointsDetailList(userPointsDetail);
        ExcelUtil<UserPointsDetail> util = new ExcelUtil<UserPointsDetail>(UserPointsDetail.class);
        util.exportExcel(response, list, "积分明细数据");
    }

    /**
     * 获取积分明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('integral:detail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(userPointsDetailService.selectUserPointsDetailById(id));
    }

    /**
     * 新增积分明细
     */
    @PreAuthorize("@ss.hasPermi('integral:detail:add')")
    @Log(title = "积分明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UserPointsDetail userPointsDetail)
    {
        return toAjax(userPointsDetailService.insertUserPointsDetail(userPointsDetail));
    }

    /**
     * 修改积分明细
     */
    @PreAuthorize("@ss.hasPermi('integral:detail:edit')")
    @Log(title = "积分明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UserPointsDetail userPointsDetail)
    {
        return toAjax(userPointsDetailService.updateUserPointsDetail(userPointsDetail));
    }

    /**
     * 删除积分明细
     */
    @PreAuthorize("@ss.hasPermi('integral:detail:remove')")
    @Log(title = "积分明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(userPointsDetailService.deleteUserPointsDetailByIds(ids));
    }
}
